package docker

import (
	"github.com/gogf/gf/v2/frame/g"

	"github.com/docker/docker/client"
)

var Docker = &docker{
	Image:     &dockerImage{},
	Container: &dockerContainer{},
	Network:   &dockerNetwork{},
	// Volume: &dockerVolume{},
}

type docker struct {
	Image     *dockerImage
	Container *dockerContainer
	Network   *dockerNetwork
	// Volume *dockerVolume
}

func (receiver *docker) NewClient() (*client.Client, error) {
	dockerConfig := g.Cfg().GetMapStrStr("beesoft.docker")

	cli, err := client.NewClient(dockerConfig["link"], dockerConfig["version"], nil, nil)
	// cli, err := client.NewEnvClient()
	// cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
	defer cli.Close()

	return cli, err
}
